feat: implement asset refresh scheduling for playlists - #499
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how playlist manifest URL refreshes are handled, moving the refresh logic from the backend to the frontend. The player now schedules a manifest refetch before the signed URL expires, ensuring uninterrupted playback without relying on backend event listeners or actions. Several backend files and tests related to the old refresh mechanism are removed, and new frontend logic and tests are added to handle the refresh process.
Frontend: Manifest Refresh Scheduling
scheduleAssetRefreshandcancelAssetRefreshtousePlaylist, which schedule and cancel a timer to reload the playlist before the manifest URL expires. The timer uses the newasset_refresh_inproperty from the backend. (resources/js/composables/playlist.ts, resources/js/composables/playlist.tsR2-R22)useShakato callscheduleAssetRefreshwhen loading a playlist andcancelAssetRefreshon reset, ensuring the manifest is refreshed at the correct time during playback. (resources/js/composables/shaka.ts, [1] [2] [3] [4]resources/js/__tests__/composables/playlist.test.ts, [1] [2]Backend: Supporting Data and Cleanup
getUrlRefreshInto thePlaylistmodel and exposed it asasset_refresh_inin the API resource, providing the frontend with the correct refresh interval. (src/Domain/Playlists/Models/Playlist.php, [1];src/App/Api/Playlists/Resources/PlaylistResource.php, [2]src/Domain/Playlists/Actions/RefreshPlaylistManifest.php, [1];src/Domain/Playlists/Listeners/RefreshExpiringPlaylistManifest.php, [2];tests/Feature/Playlist/RefreshPlaylistManifestTest.php, [3];tests/Feature/Playlist/RefreshExpiringPlaylistManifestTest.php, [4]Configuration and Documentation
config/playlists.php, config/playlists.phpL83-R85)Testing
getUrlRefreshInmethod to ensure correct calculation and clamping at zero. (tests/Feature/Playlist/PlaylistTest.php, tests/Feature/Playlist/PlaylistTest.phpR136-R153)These changes simplify the manifest refresh flow, reduce backend complexity, and ensure the player always has a valid manifest URL for uninterrupted playback.